
#ifndef FRIENDTREE_H
#define FRIENDTREE_H

#pragma once
/////////////////////////////////////////////////////////////////////////////

#include "ScrollBarEx.h"
class CFriendTree : public CTreeCtrl
{
//	DECLARE_DYNAMIC(CFriendTree)
// Construction
public:
	CFriendTree();
	virtual ~CFriendTree();
    void InitTree();
	bool isInited;
protected:
    int m_space;
    int m_ItemHeight;
// Attributes
public:
    void ScrollBarShow(bool isShow );
    INT SortItem(HTREEITEM hItem);
    void NewTextCome(int userid,LPARAM lParam);
    void NewMsgCome(int userid,LPARAM lParam);
// Operations
public:
 
    void AddUserItem(WPARAM wParam);
    void EditUserItem(WPARAM wParam);
    void DeleteUserItem(WPARAM wParam);
    void AddTypeItem(WPARAM wParam);
    void EditTypeItem(WPARAM wParam);
    void MoveTypeItem(WPARAM wParam);
    void DeleteTypeItem(WPARAM wParam);
    void Updata_JoinFriend(WPARAM wParam, LPARAM lParam);
    void Updata_FriendType(WPARAM wParam, LPARAM lParam);

protected:
    void On_Dblclk(HTREEITEM hItem);
    void DrawTitle(CDC *pDC,HTREEITEM hTreeItem,CRect rect);
    void DrawBack(CDC *pDC,int nItemState,CRect rect);
    void DrawFocusRect(CDC* pDC,LPCRECT lpRect);
    void DrawBmp(CDC *pDC,HTREEITEM hTreeItem,CRect rect,int flash);
    void DrawText(CDC *pDC,HTREEITEM hTreeItem,CRect rect);

    HTREEITEM FindUserItem(int userid);
    HTREEITEM InsertUserItem(int userid);
    void FlashUserItem(int Flash,DWORD nIDEvent);


protected:
	virtual void PreSubclassWindow();
    COLORREF crBkColor;
    COLORREF crTextColor;
	//{{AFX_MSG(CFriendTree)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnPaint();
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult);
	//}}AFX_MSG
private:
	CScrollBarEx m_HScroll;
	CScrollBarEx m_VScroll;

	DECLARE_MESSAGE_MAP()

};

#endif // FRIENDTREE_H
